home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 4 / Macwelt DVD 4.cdr / Entwickler / Mac-OS / oxygen / oxygen.app / Contents / Resources / Java / jh.jar / javax / help / FlatMap.class (.txt) < prev    next >
Encoding:
Java Class File  |  2002-06-24  |  3.6 KB  |  147 lines

  1. package javax.help;
  2.  
  3. import java.io.IOException;
  4. import java.net.MalformedURLException;
  5. import java.net.URL;
  6. import java.util.Enumeration;
  7. import java.util.MissingResourceException;
  8. import java.util.ResourceBundle;
  9. import java.util.Vector;
  10. import javax.help.Map.ID;
  11.  
  12. public class FlatMap implements Map {
  13.    private URL base;
  14.    private ResourceBundle resource;
  15.    private HelpSet helpset;
  16.    public static final String publicIDString = "-//Sun Microsystems Inc.//DTD JavaHelp Map Version 1.0//EN";
  17.    private static final boolean debug = false;
  18.  
  19.    public FlatMap(URL var1, HelpSet var2) throws IOException {
  20.       debug("Creating FlatMap for: " + var1);
  21.       Enumeration var3 = var2.getHelpSets();
  22.       if (!var3.hasMoreElements()) {
  23.          this.resource = new FlatMapResourceBundle(this, var1);
  24.          this.base = var1;
  25.          this.helpset = var2;
  26.       } else {
  27.          throw new IllegalArgumentException("Cannot create - HelpSet is not flat");
  28.       }
  29.    }
  30.  
  31.    public HelpSet getHelpSet() {
  32.       return this.helpset;
  33.    }
  34.  
  35.    public boolean isValidID(String var1, HelpSet var2) {
  36.       debug("isValidID " + var1);
  37.  
  38.       try {
  39.          this.resource.getString(var1);
  40.          return true;
  41.       } catch (MissingResourceException var4) {
  42.          return false;
  43.       }
  44.    }
  45.  
  46.    public Enumeration getAllIDs() {
  47.       return new FlatEnumeration(this.resource.getKeys(), this.helpset);
  48.    }
  49.  
  50.    public URL getURLFromID(Map.ID var1) throws MalformedURLException {
  51.       debug("getURLFromID(" + var1 + ")");
  52.       String var2 = var1.id;
  53.       HelpSet var3 = var1.hs;
  54.       if (var2 == null) {
  55.          return null;
  56.       } else {
  57.          Object var4 = null;
  58.  
  59.          try {
  60.             String var7 = this.resource.getString(var2);
  61.             URL var5 = new URL(this.base, var7);
  62.             return var5;
  63.          } catch (MissingResourceException var6) {
  64.             return null;
  65.          }
  66.       }
  67.    }
  68.  
  69.    public boolean isID(URL var1) {
  70.       Enumeration var3 = this.resource.getKeys();
  71.  
  72.       while(var3.hasMoreElements()) {
  73.          try {
  74.             String var4 = (String)var3.nextElement();
  75.             URL var2 = new URL(this.base, (String)this.resource.getObject(var4));
  76.             if (var1.sameFile(var2)) {
  77.                return true;
  78.             }
  79.          } catch (Exception var5) {
  80.          }
  81.       }
  82.  
  83.       return false;
  84.    }
  85.  
  86.    public Map.ID getIDFromURL(URL var1) {
  87.       if (var1 == null) {
  88.          return null;
  89.       } else {
  90.          String var4 = var1.toExternalForm();
  91.          Enumeration var5 = this.resource.getKeys();
  92.  
  93.          while(var5.hasMoreElements()) {
  94.             String var6 = (String)var5.nextElement();
  95.  
  96.             try {
  97.                String var2 = this.resource.getString(var6);
  98.                URL var3 = new URL(this.base, var2);
  99.                if (var3 != null) {
  100.                   String var7 = var3.toExternalForm();
  101.                   if (var4.compareTo(var7) == 0) {
  102.                      return ID.create(var6, this.helpset);
  103.                   }
  104.                }
  105.             } catch (Exception var8) {
  106.             }
  107.          }
  108.  
  109.          return null;
  110.       }
  111.    }
  112.  
  113.    public Map.ID getClosestID(URL var1) {
  114.       return this.getIDFromURL(var1);
  115.    }
  116.  
  117.    public Enumeration getIDs(URL var1) {
  118.       Object var2 = null;
  119.       Object var3 = null;
  120.       Vector var4 = new Vector();
  121.       Enumeration var5 = this.resource.getKeys();
  122.  
  123.       while(var5.hasMoreElements()) {
  124.          String var6 = (String)var5.nextElement();
  125.  
  126.          try {
  127.             String var9 = this.resource.getString(var6);
  128.             URL var10 = new URL(this.base, var9);
  129.             if (var1.sameFile(var10)) {
  130.                var4.addElement(var6);
  131.             }
  132.          } catch (Exception var8) {
  133.          }
  134.       }
  135.  
  136.       return new FlatEnumeration(var4.elements(), this.helpset);
  137.    }
  138.  
  139.    private static void debug(String var0) {
  140.    }
  141.  
  142.    // $FF: synthetic method
  143.    static void access$000(String var0) {
  144.       debug(var0);
  145.    }
  146. }
  147.